<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%> 
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ page import="dao.Shangji"%>
<%@ page import="service.*"%>
<%@ page import="util.PagingNum"%>
<%@ page import="java.util.*"%>
<%@ page import="java.net.URLEncoder"%>
<%@ page import="java.text.DateFormat"%>
<%@ page import="java.text.SimpleDateFormat"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="css/frame.css" rel="stylesheet" type="text/css" />
<title>商机管理</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">

<!-- 日历 -->
<link href="css/calendar.css" rel="stylesheet" type="text/css" />
<script>
//欢迎访问 芯晴网页特效 CsrCode.Cn
var ie =navigator.appName=="Microsoft Internet Explorer"?true:false;
function $(objID){
 return document.getElementById(objID);
}
</script>
<!-- 日历结束 -->
</head>

<body>
<!-- 页头 左边栏 -->
<%@ include file="/common/header.jsp" %>
<%@ include file="/common/left-nav.jsp" %>
<script>setLeftFrame(4,2);</script>

<%	PagingNum pagingNum=(PagingNum)request.getAttribute("shangjiPagingNum");
	String keyword=pagingNum.getKeyword();
	if(keyword==null) keyword="";
	
	int lpageIndex,npageIndex,pageIndex=pagingNum.getPageIndex();
	lpageIndex=pageIndex-1;
	npageIndex=pageIndex+1;
	
	List<Shangji> shangjis=(List<Shangji>)request.getAttribute("shangjiList");
	
	DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
%>
<!-- 此处添加本页代码 -->
<div class="mainBlock">
	<div class="mainBlockHeader">
		<li><b>我的商机！</b> 
			<html:form action="/shangjiListOwn.do">
				<html:text property="shangjiKeyword"  value="<%=keyword %>" onfocus="if(this.value=='输入关键词') this.value='';" onblur="if(this.value=='') this.value='输入关键词'"/>
				<input type="submit" value="查询">
				时间段<html:text property="startDate" size="10" onclick="showcalendar(event, this);" onfocus="showcalendar(event, this);if(this.value=='0000-00-00')this.value=''"/>
				到<html:text property="endDate" size="10" onclick="showcalendar(event, this);" onfocus="showcalendar(event, this);if(this.value=='0000-00-00')this.value=''"/>
				<input type="button" value="查询" onclick="shangjiDateQuery()">
			</html:form>
		</li>
		<script>
			function shangjiDateQuery() {
				var sd=document.getElementsByName("startDate");
				sd=sd[0].value;
				var ed=document.getElementsByName("endDate");
				ed=ed[0].value;
				var url="shangjiListOwn.do?";
				url=url+"startDate="+sd+"&endDate="+ed;
				//alert(url);
				window.location=url;
			}
		</script>
		<li><img src="img/tanhao.gif"></img>系统保留最近半年商机，如需查询之前商机，请致电客服：400.882.0656</li>
	</div>
	
	<div class="mainBlockBody">
		<div>
			<b>通过商机（</b><font color="#FF0000"><%=pagingNum.getApproveNum() %></font><b>)</b>
			<b>未通过审核（</b><font color="#FF0000"><%=pagingNum.getDenyNum() %></font><b>）</b>
			<b>总数（</b><font color="#FF0000"><%=pagingNum.getTotalNum() %></font><b>）</b>
			<div style="float:right;font-size:13px;">
				[当前<%=pagingNum.getPageIndex() %>/<%=pagingNum.getPageNum() %>页]
				<%if(lpageIndex>0) {%>
				<a href="shangjiListOwn.do?shangjiKeyword=<%=URLEncoder.encode(keyword,"UTF-8") %>&startDate=<%=pagingNum.getStartDate() %>&endDate=<%=pagingNum.getEndDate() %>&pageIndex=<%=lpageIndex %>">上一页</a>
				<%} %>
				<%int pages[]=pagingNum.getPageIndexes();
					for(int i=0;i<pages.length;i++) {
						if(pages[i]==0)	break;
						if(pages[i]==pagingNum.getPageIndex()) {
						%>
						<%=pages[i] %>
						<%} else {%>
						<a href="shangjiListOwn.do?shangjiKeyword=<%=URLEncoder.encode(keyword,"UTF-8") %>&startDate=<%=pagingNum.getStartDate() %>&endDate=<%=pagingNum.getEndDate() %>&pageIndex=<%=pages[i] %>"><%=pages[i] %></a>
						<%} %>
					<%} %>
				<%if(npageIndex<=pagingNum.getPageNum()) {%>
				<a href="shangjiListOwn.do?shangjiKeyword=<%=URLEncoder.encode(keyword,"UTF-8") %>&startDate=<%=pagingNum.getStartDate() %>&endDate=<%=pagingNum.getEndDate() %>&pageIndex=<%=npageIndex %>">下一页</a>
				<%} %>
			</div>
		</div>
		
		
		<table width="100%" cellpadding="0" cellspacing="0" border="1px" >
			<tr align="center" height="35px">
				<!-- <th width="10%">商机来源</th> -->
				<th width="45%">标题</th>
				<th width="15%">关键词</th>
				<th width="15%">发布日期</th>
				<th width="10%">审核状态</th>
				<th width="5%">点击</th>
				<th width="10%">操作</th>
			</tr>
		<%for(int i=0;i<shangjis.size();i++) {
			Shangji temp=shangjis.get(i);
			if(temp.getShangjikeyword()==null)	temp.setShangjikeyword("");
			if(temp.getShangjistatus().toLowerCase().equals("pending"))		temp.setShangjistatus("审核中");
			else if(temp.getShangjistatus().toLowerCase().equals("approved"))	temp.setShangjistatus("通过");
			else if(temp.getShangjistatus().toLowerCase().equals("deny"))		temp.setShangjistatus("未通过");
		%>
			<tr align="center" height="30px">
				<td><%=temp.getShangjititle() %></td>
				<td><%=temp.getShangjikeyword() %></td>
				<td><%=temp.getSubmitdate().toString().substring(0,19) %></td>
				<td><%=temp.getShangjistatus() %></td>
				<td>0</td>
				<td>
					<a href="shangjiIdOwn.do?shangjiID=<%=temp.getShangjiid() %>">[查看]</a>
					
					<%if(temp.getShangjistatus().equals("未通过")) {%>
					<a href="shangjiIdDelOwn.do?shangjiID=<%=temp.getShangjiid() %>" onclick="return confirm('是否确认删除');">[删除]</a>
					<%} %>
				</td>
			</tr>
		
		<%} %>
		</table>
	</div>

</div>

<!-- 页脚 -->
<%@ include file="/common/footer.jsp" %>
</body>
<script src="jslab/calendar.js" type="text/javascript"></script>
</html>